USE [kymedi2b2data]
GO

/****** Object:  Trigger [dbo].[trig_QRI_genSQL]    Script Date: 10/22/2012 3:10:49 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE trigger [dbo].[trig_QRI_genSQL] on [dbo].[QT_QUERY_RESULT_INSTANCE]
  FOR INSERT
  AS 
  UPDATE dbo.QT_QUERY_MASTER
  SET dbo.QT_QUERY_MASTER.GENERATED_SQL_v2 = dbo.genSQL(dbo.QT_QUERY_MASTER.REQUEST_XML, i.QUERY_INSTANCE_ID)
  FROM INSERTED i
  where dbo.qt_query_master.QUERY_MASTER_ID = (select dbo.qt_query_instance.QUERY_MASTER_ID from 
											   dbo.qt_query_instance where dbo.qt_query_instance.QUERY_INSTANCE_ID = i.QUERY_INSTANCE_ID)



GO


